<template>
  <div class="home">
    <el-container style="height: 90%; border: 1px solid #eee">
  <el-aside width="200px" style="background-color: rgb(238, 241, 246)">
    <!-- unique-opened router :default-active="this.$router.path" 配置菜单采用路由 -->
    <el-menu unique-opened router :default-active="this.$router.path" :default-openeds="[]">
      <el-menu-item index="/home/worktable">
        <i class="el-icon-setting"></i>
        <span slot="title">工作台</span>
      </el-menu-item>
      <el-submenu :index="index+''" v-for="(menu,index) in menus" :key="menu.id">
        <template slot="title"><i class="el-icon-message"></i>{{menu.menu_name}}</template>
        <el-menu-item-group v-for="(childMenu) in menu.childMenus" :key="childMenu.id">
          <el-menu-item :index="childMenu.link_url+''">{{childMenu.menu_name}}</el-menu-item>
        </el-menu-item-group>
    
      </el-submenu>
      
    </el-menu>
  </el-aside>


  
  
  <el-container>
    <el-header style="text-align: right; font-size: 12px">
      <el-dropdown>
        <el-breadcrumb separator-class="el-icon-arrow-right">
  <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
  <el-breadcrumb-item>活动管理</el-breadcrumb-item>
  <el-breadcrumb-item>活动列表</el-breadcrumb-item>
  <el-breadcrumb-item>活动详情</el-breadcrumb-item>
</el-breadcrumb>
        <i class="el-icon-setting" style="margin-right: 15px"></i>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item>查看</el-dropdown-item>
          <el-dropdown-item>新增</el-dropdown-item>
          <el-dropdown-item @click.native="outLogin">退出</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
      <span>{{userName.user_name}}</span>
    </el-header>
    
    <el-main>
        <router-view></router-view>
    </el-main>
  </el-container>
</el-container>
  </div>
</template>
<style>
  .el-header {
    background-color: #B3C0D1;
    color: #333;
    line-height: 60px;
  }
  
  .el-aside {
    color: #333;
  }
</style>

<script>
  export default {
    data() {
      const item = {
        date: '2016-05-02',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1518 弄'
      };
      return {
        menus:[],
        tableData: Array(10).fill(item),
        userName:eval("(" + sessionStorage.getItem("userName") + ")")  
      }
    },
    created(){
      this.axios.post("/api/hj/queryUserById")
      .then(result=>{
        this.menus=result.data;
      })
    },
    methods:{
      outLogin(){
        sessionStorage.clear();
        this.$router.push("/login")
      }
    }
  };
</script>